import http from '@/http/index'

export const getProductListApi = (params: any): RES<IListModel<IProductModel>> => http.get('/product/list', { params })

//商品列表页数据
export const productListApi = (params: IListParams): RES<IListModel<IProductModel>> => http.get("/product/list", { params })

// 商品分类的数据
export const productCategoryListApi = (params: IListParams): RES<IListModel<IClassificationData>> => http.get(`/productCategory/list/${params.parentId}?pageNum=${params.pageNum}&pageSize=${params.pageSize}`)



// 修改商品分类的导航栏状态
export const updateNavStatusApi = (ids: number[], navStatus: number): RES<number> => http.post(`/productCategory/update/navStatus?ids=${ids.join(",")}&navStatus=${navStatus}`)
// 修改商品分类的显示状态
export const updateShowStatusApi = (ids: number[], showStatus: number): RES<number> => http.post(`/productCategory/update/showStatus?ids=${ids.join(",")}&showStatus=${showStatus}`)

// 所有一级分类及子分类的数据
export const withChildrenListApi = (): RES<any> => http.get('/productCategory/list/withChildren')

// 商品属性分类及其下属性的数据
export const withAttrListApi = (): RES<IwithAttr[]> => http.get('/productAttribute/category/list/withAttr')

// 提交添加商品分类
export const createAttrListApi = (params: IcreateAttrList): RES<number> => http.post('/productCategory/create', params)

// 编辑商品分类获取对应id数据
export const productCategoryAttrIdApi = (id: any): RES<IEditProductClass> => http.get(`/productCategory/${id}`)

// 修改商品分类
export const modifyAttrListApi = (id: number, productCategoryParam: IcreateAttrList): RES<number> => http.post(`/productCategory/update/${id}`, productCategoryParam)

// 删除商品分类
export const deleteAttrApi = (id: number): RES<number> => http.post(`/productCategory/delete/${id}`)

// 获取属性管理页数据
export const addProductAttrApi = (params: IListParams): RES<IProductAttr> => http.get(`/productAttribute/category/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`)

// 添加商品属性
export const addAttributeApi = (name: string): RES<number> => http.post(`/productAttribute/category/create?name=${name}`)

// 修改商品属性分类
export const editAttributeApi = (id: number, name: string): RES<number> => http.post(`/productAttribute/category/update/${id}?name=${name}`)

// 删除指定商品属性分类
export const delAttributeApi = (id: number): RES<number> => http.get(`/productAttribute/category/delete/${id}`)

// /mall-admin/brand/list 根据品牌名称分页获取品牌列表
export const getBrandListApi = (params: IUserListParams): RES<BrandObject> => http.get('/brand/list', { params })
// 根据分类查询属性列表或参数列表
export const AttributeListApi = (params: IListParams): RES<IListModel<IAttributeList[]>> => http.get(`/productAttribute/list/${params.cid}?pageNum=${params.pageNum}&pageSize=${params.pageSize}&type=${params.type}`)

// /mall-admin/brand/create 添加品牌
export const BrandCreateApi = (params: IBrandCreate): RES<number> => http.post('/brand/create', params)

// /mall-admin/brand/update/factoryStatus 批量更新厂家制造商状态
export const FactoryStatusApi = (id: number[], factoryStatus: number): RES<number> => http.post(`/brand/update/factoryStatus?ids=${id}&factoryStatus=${factoryStatus}`)

// /mall-admin/brand/update/showStatus 批量更新显示状态
export const ShowStatusApi = (id: number[], showStatus: number): RES<number> => http.post(`/brand/update/showStatus?ids=${id}&showStatus=${showStatus}`)

// /mall-admin/brand/delete/{id} 删除品牌
export const BrandDeleteApi = (id: number): RES<number> => http.get(`/brand/delete/${id}`)

// /mall-admin/brand/{id} 根据编号查询品牌信息
export const getBrandIdApi = (id: number): RES<BrandList> => http.get(`/brand/${id}`)

// /mall-admin/brand/update/{id} 更新品牌
export const BrandUpdateApi = (id: number, params: IBrandCreate): RES<number> => http.post(`/brand/update/${id}`, params)
// 添加商品属性信息
export const addProductAttributeApi = (productAttributeParam: IAttributeList): RES<number> => http.post("/productAttribute/create", productAttributeParam)


// 查询单个商品属性
export const ProductAttributeApi = (id: any): RES<IAttributeList> => http.get(`/productAttribute/${id}`)

// 修改商品属性信息
export const updateProductAttributeApi = (id: any, productAttributeParam: IAttributeList): RES<number> => http.post(`/productAttribute/update/${id}`, productAttributeParam)

// 修改商品属性信息
export const delProductAttributeApi = (ids: number[]): RES<number> => http.post(`/productAttribute/delete?ids=${ids.join(',')}`)

// 点击修改上架状态
export const publishStatusApi = (ids: number[], publishStatus: number): RES<number> => http.post(`/product/update/publishStatus?ids=${ids.join(",")}&publishStatus=${publishStatus}`)

// 点击修改新品状态
export const newStatusApi = (ids: number[], newStatus: number): RES<number> => http.post(`/product/update/newStatus?ids=${ids.join(",")}&newStatus=${newStatus}`)

// 点击修改推荐状态
export const recommendStatusApi = (ids: number[], recommendStatus: number): RES<number> => http.post(`/product/update/recommendStatus?ids=${ids.join(",")}&recommendStatus=${recommendStatus}`)

// 点击删除
export const delStatusApi = (ids: number[]): RES<number> => http.post(`/product/update/deleteStatus?ids=${ids.join(",")}&deleteStatus=1`)


// 获取货品信息
export const skuApi = (pid: number, keyword: string): RES<SkuModel[]> => http.get(`/sku/${pid}?keyword=${keyword}`)


export const updateSkuAPI = (pid:number,skuStockList:SkuModel[]): RES<number> =>
    http.post(`/sku/update/${pid}`, skuStockList);